const {parseSetCookie, md5} = require("../utils/fun");
const {request} = require("../utils/request");
const LoginBo = require("./login-bo");

const ACCESS_KEY = "yWpx3hWQHFhSnTCj#{}#6KuRKuaAjLJ5sYRy"

class UserBo{
    gameId = null
    serverId = null
    roleId = null
    userName = null
    deviceinfo = null
    headers = {}


    constructor(gameId, serverId, roleId, userName) {
        this.gameId = gameId
        this.serverId = serverId
        this.roleId = roleId
        this.userName = userName
        this.init()
    }

    init(){

    }

    setDeviceInfo(info){
        this.deviceinfo = info
        return this
    }
    setClientIp(ip){
        if(ip){
            this.headers['HTTP_X_FORWARDED_FOR'] = ip
            this.headers['HTTP_CLIENT_IP'] = ip
        }
        return this
    }

    setCookies(cookies){
        if(cookies) {
            this.headers['COOKIE'] = parseSetCookie(cookies)
        }
        return this
    }

    getCommonParams (){
        return {
            gameId: this.gameId,
            serverId:this.serverId,
            roleId : this.roleId,
            userName : this.userName,
            deviceinfo:this.deviceinfo
        }
    }

    /**
     * 登录到抽奖中心
     */
    async doLoginToLottery (userModel, gameModel){
        let loginBo = new LoginBo(userModel, gameModel)
        return await loginBo.doLoginToLottery()
    }



}

module.exports = UserBo